import { createFileRoute } from '@tanstack/react-router'
import { AuthenticatedLayout } from '@/components/layout/authenticated-layout'
import { useAuthStore } from '@/stores/authStore'
import { adminInfo } from '@/api/account'
export const Route = createFileRoute('/_authenticated')({
  component: AuthenticatedLayout,

  loader: async ({ context }) => {
    const queryClient = context.queryClient
    const res = await queryClient.ensureQueryData({
      queryKey: ['adminInfo'],
      queryFn: adminInfo,
    })
    const setUser = useAuthStore.getState().setUser
    setUser(res.data.data)
  },
})
